package tanxin;

import java.util.Arrays;

public class HaiDaoYunHuo {
    public static void main(String[] args) {
        //定义载重容量
        int capacity = 30;
        //货物 //无序，先进行排序
        int[] goods = {3, 5, 4, 10, 7, 14, 2, 11};
        //升序，由小到大
        Arrays.sort(goods);
        int nums = 0;
        while (capacity >= goods[nums]){

            capacity = capacity - goods[nums];

            System.out.println("装了" + (nums+1) + "件货物，剩余容量：" + capacity);

            nums ++;
        }

    }
}
